import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';

import '../constant/constant.dart';

// ignore: must_be_immutable
class AppNavBar extends StatefulWidget {
  PageController pageController;
  int index;
  GlobalKey<CurvedNavigationBarState> barKey;
  void Function(int index) onPageTap;
  // bool ignoreListener;
  // AppNavBar({required this.pageController, required this.index, Key? key})
  //     : super(key: key);
  AppNavBar(
      {required this.pageController,
      required this.index,
      required this.barKey,
      required this.onPageTap,
      // required this.ignoreListener,

      super.key});
  @override
  State<AppNavBar> createState() => AppNavBarState();
}

class AppNavBarState extends State<AppNavBar> {
  int ona = 1;
  // void printP() {
  //   print("function invoke");
  // }

  @override
  Widget build(BuildContext context) {
    // GlobalKey<CurvedNavigationBarState> _bottomNavigationKey = GlobalKey();
    return Container(
      decoration: BoxDecoration(
        boxShadow: [
          BoxShadow(
            color: appBlack.withOpacity(0.1),
            blurRadius: 1.0,
            spreadRadius: 1.0,
            offset: const Offset(0.0, -1.0),
          )
        ],
      ),
      child: NavigationBarTheme(
        data: NavigationBarThemeData(
          elevation: 0,
          backgroundColor: Colors.transparent,
          indicatorColor: Colors.transparent,
          shadowColor: Colors.transparent,
          labelTextStyle: MaterialStatePropertyAll(
            Theme.of(context).textTheme.bodySmall!.copyWith(color: appRed),
          ),
        ),
        child: CurvedNavigationBar(
          key: widget.barKey,
          index: widget.index,
          height: 60.0,
          items: const <Widget>[
            Icon(Icons.home, size: 30),
            Icon(Icons.favorite_sharp, size: 30),
            Icon(Icons.add, size: 30),
            Icon(Icons.chat, size: 30),
            Icon(Icons.person, size: 30),
          ],
          color: bottomBarBgColor,
          buttonBackgroundColor: bottomBarButtonColor,
          backgroundColor: bottomBarWaweColor,

          animationCurve: Curves.easeInOut,
          animationDuration: const Duration(milliseconds: 300),
          onTap: (index) {
            widget.onPageTap(index);
          },
          // letIndexChange: (index) => true,
        ),
      ),
    );
  }
}


// var originBar = NavigationBar(
//   backgroundColor: Colors.white,
//   surfaceTintColor: Colors.white,
//   labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
//   onDestinationSelected: (int index) {},
//   indicatorColor: Colors.transparent,
//   selectedIndex: 0,
//   height: 56.0,
//   destinations: const [
//     NavigationDestination(
//       icon: Icon(Icons.search_outlined),
//       label: 'Explore',
//       selectedIcon: Icon(
//         Icons.search,
//         color: appRed,
//       ),
//     ),
//     NavigationDestination(
//       icon: Icon(Icons.favorite_border_outlined),
//       label: 'Wishlist',
//       selectedIcon: Icon(
//         Icons.favorite,
//         color: appRed,
//       ),
//     ),
//     NavigationDestination(
//       icon: Icon(Icons.wb_sunny_outlined),
//       label: 'Trips',
//       selectedIcon: Icon(
//         Icons.wb_sunny,
//         color: appRed,
//       ),
//     ),
//     NavigationDestination(
//       icon: Icon(Icons.message_outlined),
//       label: 'Inbox',
//       selectedIcon: Icon(
//         Icons.message,
//         color: appRed,
//       ),
//     ),
//     NavigationDestination(
//       icon: Icon(Icons.person_outline),
//       label: 'Log in',
//       selectedIcon: Icon(
//         Icons.person,
//         color: appRed,
//       ),
//     ),
//   ],
// );

